package com.itheima.dao.store;

import com.itheima.domain.store.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *  course的增删改查
 *  2021/10/16
 *  create by guowenliang
 */
public interface CourseMapper {
    // 查询所有course,根据更新时间降序排列
    @Select("select * from st_course order by update_time desc")
    List<Course> findAll();

    // 添加course
    @Insert("insert into st_course (id,name,remark,state,create_by,create_time,update_by,update_time) " +
                        "values (#{id},#{name},#{remark},#{state},#{createBy},now(),#{updateBy},now())")
    void addCourse(Course course);

    // 修改course
    @Update("update st_course set name=#{name},remark=#{remark},state=#{state} where id=#{id}")
    void updateCourse(Course course);

    // 删除course
    @Delete("delete from st_course where id=#{id}")
    void deleteCourse(@Param("id") String id);

    // 通过id查询course
    @Select("select * from st_course where id=#{id}")
    Course findCourseById(@Param("id") String id);
}
